<?php

namespace app\common\service\order\pipeline\coupon;

use app\common\service\order\coupon_order\coupon\CouponOrderBuild;
use app\model\CouponOrder;
use app\model\CouponProductChannel;
use think\Exception;

class TestLimitMoney
{

    const LIMIT_MONEY = 100;// 1元

    public static function handle(CouponOrder $couponOrder, $next)
    {


        $params = $couponOrder->params;
        $serv_type = $params['serv_type'] ?? '';

        if ($serv_type != PRODUCT_COUPON_SERV) {
            return $next($couponOrder);
        }

        $buildService = new CouponOrderBuild($couponOrder);
        $payAmount = $buildService->pay_amount;

        if ($payAmount > self::LIMIT_MONEY  && !isProd() && !isLocal()){
            throw new Exception('测试环境不能充值大于1块钱的产品');
        }


        $next($couponOrder);
    }
}